package nc.bs.lmzb.comments.plandetail;

import java.sql.ResultSet;
import java.sql.SQLException;

import nc.bs.dao.BaseDAO;
import nc.bs.logging.Logger;
import nc.jdbc.framework.processor.ResultSetProcessor;

public class LmPubDMO {
	
	private  BaseDAO dmo = null;
	
	public BaseDAO getDmo() {
		if(dmo == null){
			dmo = new BaseDAO();
		}
		return dmo;
	}
	
	public String queryBySQL(String sql) {
		String value = "";
		try {
			if (sql == null || "".equals(sql)) {
				return value;
			}
			ResultSetProcessor p = new ResultSetProcessor() {
				public Object handleResultSet(ResultSet rs) throws SQLException {
					String str = null;
					if (rs.next()) {
						str = rs.getString(1);
					}
					return str;
				}
			};
			value = (String) getDmo().executeQuery(sql, p);
		} catch (Exception e) {
			Logger.info(e);
		}
		return value;
	}
	public int updateSQL(String sql) {
		int count = -1;
		try {
			if (sql == null || "".equals(sql)) {
				return count;
			}
			count = getDmo().executeUpdate(sql);
		} catch (Exception e) {
			Logger.info(e);
		}
		return count;
	}
}
